package com.book.book.mapper;

import com.book.book.model.BookInfo;
import com.book.book.model.PageRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface bookInfoMapper {
    @Select("select *from book_info")
 List<BookInfo>getList();

    @Insert("INSERT INTO book_info(book_name,author,count,price,publish,`status`)" +
            "VALUES(#{bookName},#{author},#{count},#{price},#{publish},#{status})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
 Integer addBook(BookInfo bookInfo);

    @Select("select *from book_info where `status`!=0 LIMIT #{offset},#{pageSize}")
List<BookInfo>selectBooksByPage(PageRequest pageRequest);

    @Select("select count(1) from book_info where `status`!=0")
    Integer count();

    @Select("select *from book_info where `status`!=0 and id=#{bookId}")
    BookInfo queryBookById(@Param("bookId") Integer bookId);

    Integer updateBook(BookInfo bookInfo);

    Integer batchDeleteBook(List<Integer> ids);
}
